/*
 * EpikSocket.h
 *
 *  Created on: Jul 31, 2010
 *      Author: Justin
 *
 * EXAMPLE
   	EpikSocket s("192.168.1.105", 1337);
	s.SendLine("PING");
 */
#ifndef EPIKSOCKET_H_
#define EPIKSOCKET_H_

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pspnet.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <errno.h>

class Socket
{
	static const char NEWLINE_;
	int sock_;
	int port_;

	struct timeval tv_;
	struct sockaddr_in servAddr_;
	struct hostent *server_;

public:
	Socket( char* host, uint16_t port );
	~Socket();

//	EpikSocket& operator<< ( const std::string &) const;
	void Send(const char *msg) const;
	void SendLine(const char *msg) const;
	void Flush() const;

//	EpikSocket& operator>> ( std::string& ) const;
	int Recv(char *buf, u16 size) const;
	int GetMacAddr(unsigned char[4]) const;
};

#endif /* EPIKSOCKET_H_ */
